//
//  FKModifyLoginPwdVC.m
//  inspectVehicle
//
//  Created by Macbook Pro on 2018/12/10.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKModifyLoginPwdVC.h"
#import "FKFindLoginPwdVC.h"

@interface FKModifyLoginPwdVC ()

@property (weak, nonatomic) IBOutlet UITextField *oldPwdField;
@property (weak, nonatomic) IBOutlet UITextField *pwdField;
@property (weak, nonatomic) IBOutlet UITextField *againPwdField;

@end

@implementation FKModifyLoginPwdVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (IBAction)forgotPwdBtbClicked:(UIButton *)sender {
    FKFindLoginPwdVC *vc = [[UIStoryboard storyboardWithName:@"FKFindLoginPwdVC" bundle:nil] instantiateInitialViewController];
    fkPushNav(vc);
}

- (IBAction)confirmBtnClicked:(UIButton *)sender {
    [self.view endEditing:true];
    
    if (self.oldPwdField.text.length < 1) {
        [SVProgressHUD showInfoWithStatus:self.oldPwdField.placeholder];
        return;
    }
    if (self.pwdField.text.length < 1) {
        [SVProgressHUD showInfoWithStatus:self.pwdField.placeholder];
        return;
    }
    if (self.againPwdField.text.length < 1) {
        [SVProgressHUD showInfoWithStatus:self.againPwdField.placeholder];
        return;
    }
    if (![self.pwdField.text isEqualToString:self.againPwdField.text]) {
        [SVProgressHUD showInfoWithStatus:@"新密码与确认密码不一致!"];
        return;
    }
    
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"old_pwd"] = self.oldPwdField.text;
    param[@"new_pwd"] = self.pwdField.text;
    param[@"new_again_pwd"] = self.againPwdField.text;
    param[@"type"] = @"2";
    [SVProgressHUD show];
    [FKHttpTool postWithSuffix:@"m=App&c=Member&a=setLoginPwd" param:param success:^(FKBaseResult *result) {
        if (result.isSuccess) {
            [SVProgressHUD dismiss];
            [SVProgressHUD showSuccessWithStatus:@"登录密码修改成功!"];
            fkPopVC;
        }
    } failure:nil];
}

@end
